Skip to content

Fix resource leaks#82

Open
clayton-shopify wants to merge 1 commit into
twalpole:masterfrom
Shopify:fix-resource-leaks
Open

Fix resource leaks#82
clayton-shopify wants to merge 1 commit into
twalpole:masterfrom
Shopify:fix-resource-leaks

Conversation

@clayton-shopify
Copy link
Copy Markdown

@clayton-shopify clayton-shopify commented Sep 8, 2021

After quitting a local Chrome session, two threads (one running cleanup_async_responses, and one running process_messages) continue executing forever. This uses up memory and CPU time. If many sessions are started and quit, all available memory will eventually be consumed.

To demonstrate the problem, run this code and keep the Ruby interpreter running:

10.times do
  session = Capybara.current_session
  session.visit("about:blank")
  session.quit
end

Observe (for instance, using top -H) that 20 threads remain.

To fix the problem, I've added exit conditions to the two problematic loops. I'm not sure whether checking the status of @ws is the best approach, but it works in my testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant